<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: BoardFactory</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.board</a> ]
    </div>

    <h1>Coverage Summary for Class: BoardFactory (nl.tudelft.jpacman.board)</h1>

    <table class="coverageStats">

        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">BoardFactory</td>
            <td class="coverageStat">
  <span class="percent">
    20%
  </span>
                <span class="absValue">
    (1/ 5)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    5.3%
  </span>
                <span class="absValue">
    (1/ 19)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">BoardFactory$Ground</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 3)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 5)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">BoardFactory$MockitoMock$2131606845</td>
        </tr>
        <tr>
            <td class="name">BoardFactory$MockitoMock$2131606845$auxiliary$BFYsz9FZ</td>
        </tr>
        <tr>
            <td class="name">BoardFactory$MockitoMock$2131606845$auxiliary$HsqleMMb</td>
        </tr>
        <tr>
            <td class="name">BoardFactory$MockitoMock$2131606845$auxiliary$thDQXrvd</td>
        </tr>
        <tr>
            <td class="name">BoardFactory$MockitoMock$2131606845$auxiliary$WkZGPRkB</td>
        </tr>
        <tr>
            <td class="name">BoardFactory$MockitoMock$2131606845$auxiliary$Z4GGt3we</td>
        </tr>
        <tr>
            <td class="name">BoardFactory$Wall</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 3)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 5)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name"><strong>total</strong></td>
            <td class="coverageStat">
  <span class="percent">
    9.1%
  </span>
                <span class="absValue">
    (1/ 11)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    3.4%
  </span>
                <span class="absValue">
    (1/ 29)
  </span>
            </td>
        </tr>
    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.board;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;import nl.tudelft.jpacman.sprite.PacManSprites;
        <i>4</i>&nbsp;import nl.tudelft.jpacman.sprite.Sprite;
        <i>5</i>&nbsp;
        <i>6</i>&nbsp;/**
        <i>7</i>&nbsp; * A factory that creates {@link Board} objects from 2-dimensional arrays of
        <i>8</i>&nbsp; * {@link Square}s.
        <i>9</i>&nbsp; *
        <i>10</i>&nbsp; * @author Jeroen Roosen
        <i>11</i>&nbsp; */
        <b class="fc"><i>12</i>&nbsp;public class BoardFactory {</b>
        <i>13</i>&nbsp;
        <i>14</i>&nbsp; /**
        <i>15</i>&nbsp; * The sprite store providing the sprites for the background.
        <i>16</i>&nbsp; */
        <i>17</i>&nbsp; private final PacManSprites sprites;
        <i>18</i>&nbsp;
        <i>19</i>&nbsp; /**
        <i>20</i>&nbsp; * Creates a new BoardFactory that will create a board with the provided
        <i>21</i>&nbsp; * background sprites.
        <i>22</i>&nbsp; *
        <i>23</i>&nbsp; * @param spriteStore
        <i>24</i>&nbsp; * The sprite store providing the sprites for the background.
        <i>25</i>&nbsp; */
        <b class="nc"><i>26</i>&nbsp; public BoardFactory(PacManSprites spriteStore) {</b>
        <b class="nc"><i>27</i>&nbsp; this.sprites = spriteStore;</b>
        <b class="nc"><i>28</i>&nbsp; }</b>
        <i>29</i>&nbsp;
        <i>30</i>&nbsp; /**
        <i>31</i>&nbsp; * Creates a new board from a grid of cells and connects it.
        <i>32</i>&nbsp; *
        <i>33</i>&nbsp; * @param grid
        <i>34</i>&nbsp; * The square grid of cells, in which grid[x][y] corresponds to
        <i>35</i>&nbsp; * the square at position x,y.
        <i>36</i>&nbsp; * @return A new board, wrapping a grid of connected cells.
        <i>37</i>&nbsp; */
        <i>38</i>&nbsp; public Board createBoard(Square[][] grid) {
        <b class="nc"><i>39</i>&nbsp; assert grid != null;</b>
        <i>40</i>&nbsp;
        <b class="nc"><i>41</i>&nbsp; Board board = new Board(grid);</b>
        <i>42</i>&nbsp;
        <b class="nc"><i>43</i>&nbsp; int width = board.getWidth();</b>
        <b class="nc"><i>44</i>&nbsp; int height = board.getHeight();</b>
        <b class="nc"><i>45</i>&nbsp; for (int x = 0; x &lt; width; x++) {</b>
        <b class="nc"><i>46</i>&nbsp; for (int y = 0; y &lt; height; y++) {</b>
        <b class="nc"><i>47</i>&nbsp; Square square = grid[x][y];</b>
        <b class="nc"><i>48</i>&nbsp; for (Direction dir : Direction.values()) {</b>
        <b class="nc"><i>49</i>&nbsp; int dirX = (width + x + dir.getDeltaX()) % width;</b>
        <b class="nc"><i>50</i>&nbsp; int dirY = (height + y + dir.getDeltaY()) % height;</b>
        <b class="nc"><i>51</i>&nbsp; Square neighbour = grid[dirX][dirY];</b>
        <b class="nc"><i>52</i>&nbsp; square.link(neighbour, dir);</b>
        <i>53</i>&nbsp; }
        <i>54</i>&nbsp; }
        <i>55</i>&nbsp; }
        <i>56</i>&nbsp;
        <b class="nc"><i>57</i>&nbsp; return board;</b>
        <i>58</i>&nbsp; }
        <i>59</i>&nbsp;
        <i>60</i>&nbsp; /**
        <i>61</i>&nbsp; * Creates a new square that can be occupied by any unit.
        <i>62</i>&nbsp; *
        <i>63</i>&nbsp; * @return A new square that can be occupied by any unit.
        <i>64</i>&nbsp; */
        <i>65</i>&nbsp; public Square createGround() {
        <b class="nc"><i>66</i>&nbsp; return new Ground(sprites.getGroundSprite());</b>
        <i>67</i>&nbsp; }
        <i>68</i>&nbsp;
        <i>69</i>&nbsp; /**
        <i>70</i>&nbsp; * Creates a new square that cannot be occupied by any unit.
        <i>71</i>&nbsp; *
        <i>72</i>&nbsp; * @return A new square that cannot be occupied by any unit.
        <i>73</i>&nbsp; */
        <i>74</i>&nbsp; public Square createWall() {
        <b class="nc"><i>75</i>&nbsp; return new Wall(sprites.getWallSprite());</b>
        <i>76</i>&nbsp; }
        <i>77</i>&nbsp;
        <i>78</i>&nbsp; /**
        <i>79</i>&nbsp; * A wall is a square that is inaccessible to anyone.
        <i>80</i>&nbsp; *
        <i>81</i>&nbsp; * @author Jeroen Roosen
        <i>82</i>&nbsp; */
        <i>83</i>&nbsp; private static final class Wall extends Square {
        <i>84</i>&nbsp;
        <i>85</i>&nbsp; /**
        <i>86</i>&nbsp; * The background for this square.
        <i>87</i>&nbsp; */
        <i>88</i>&nbsp; private final Sprite background;
        <i>89</i>&nbsp;
        <i>90</i>&nbsp; /**
        <i>91</i>&nbsp; * Creates a new wall square.
        <i>92</i>&nbsp; *
        <i>93</i>&nbsp; * @param sprite
        <i>94</i>&nbsp; * The background for the square.
        <i>95</i>&nbsp; */
        <b class="nc"><i>96</i>&nbsp; Wall(Sprite sprite) {</b>
        <b class="nc"><i>97</i>&nbsp; this.background = sprite;</b>
        <b class="nc"><i>98</i>&nbsp; }</b>
        <i>99</i>&nbsp;
        <i>100</i>&nbsp; @Override
        <i>101</i>&nbsp; public boolean isAccessibleTo(Unit unit) {
        <b class="nc"><i>102</i>&nbsp; return false;</b>
        <i>103</i>&nbsp; }
        <i>104</i>&nbsp;
        <i>105</i>&nbsp; @Override
        <i>106</i>&nbsp; public Sprite getSprite() {
        <b class="nc"><i>107</i>&nbsp; return background;</b>
        <i>108</i>&nbsp; }
        <i>109</i>&nbsp; }
        <i>110</i>&nbsp;
        <i>111</i>&nbsp; /**
        <i>112</i>&nbsp; * A ground square is a square that is accessible to anyone.
        <i>113</i>&nbsp; *
        <i>114</i>&nbsp; * @author Jeroen Roosen
        <i>115</i>&nbsp; */
        <i>116</i>&nbsp; private static final class Ground extends Square {
        <i>117</i>&nbsp;
        <i>118</i>&nbsp; /**
        <i>119</i>&nbsp; * The background for this square.
        <i>120</i>&nbsp; */
        <i>121</i>&nbsp; private final Sprite background;
        <i>122</i>&nbsp;
        <i>123</i>&nbsp; /**
        <i>124</i>&nbsp; * Creates a new ground square.
        <i>125</i>&nbsp; *
        <i>126</i>&nbsp; * @param sprite
        <i>127</i>&nbsp; * The background for the square.
        <i>128</i>&nbsp; */
        <b class="nc"><i>129</i>&nbsp; Ground(Sprite sprite) {</b>
        <b class="nc"><i>130</i>&nbsp; this.background = sprite;</b>
        <b class="nc"><i>131</i>&nbsp; }</b>
        <i>132</i>&nbsp;
        <i>133</i>&nbsp; @Override
        <i>134</i>&nbsp; public boolean isAccessibleTo(Unit unit) {
        <b class="nc"><i>135</i>&nbsp; return true;</b>
        <i>136</i>&nbsp; }
        <i>137</i>&nbsp;
        <i>138</i>&nbsp; @Override
        <i>139</i>&nbsp; public Sprite getSprite() {
        <b class="nc"><i>140</i>&nbsp; return background;</b>
        <i>141</i>&nbsp; }
        <i>142</i>&nbsp; }
        <i>143</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
